package com.ibatis.jpetstore.service;

import java.util.ArrayList;
import java.util.List;

import com.ibatis.dao.client.DaoManager;
import com.ibatis.jpetstore.domain.Account;
import com.ibatis.jpetstore.domain.Iplock;
import com.ibatis.jpetstore.persistence.iface.AccountDao;
import com.ibatis.jpetstore.persistence.DaoConfig;

public class AccountService {

  private AccountDao accountDao;

  public AccountService() {
    DaoManager daoMgr = DaoConfig.getDaoManager();
    this.accountDao = (AccountDao) daoMgr.getDao(AccountDao.class);
  }

  public AccountService(AccountDao accountDao) {
    this.accountDao = accountDao;
  }

  public Account getAccount(String username) {
    return accountDao.getAccount(username);
  }

  public Account getAccount(String username, String password) {
    return accountDao.getAccount(username, password);
  }

  public void insertAccount(Account account) {
    accountDao.insertAccount(account);
  }

  public void updateAccount(Account account) {
    accountDao.updateAccount(account);
  }
  
  public List getAllIpAddList()
  {
	List addList=  accountDao.getAllIpLockList();
	List resultList=new ArrayList();
	
	
	for (int i=0;addList!=null&&i<addList.size();i++)
	{
		Iplock iplock =(Iplock)addList.get(i);
		resultList.add(iplock.getAdd_1()+"."+iplock.getAdd_2()+"."+iplock.getAdd_3()+"."+iplock.getAdd_4());
	}
	
	
	return resultList;
  }

}
